package com.example.eliliya.simple_play;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.widget.Toast;
import com.example.eliliya.simple_play.R;

/**
 * Created by EliLiya on 2018/5/30.
 */

public class MusicService extends Service{
    private MediaPlayer mPlayer;
    public void onCreate(){
        mPlayer=MediaPlayer.create(getApplicationContext(),R.raw.gequ);
        mPlayer.setLooping(true);
        super.onCreate();
    }
    public void onStart(Intent intent,int startId){
        Toast.makeText(MusicService.this,"MusicSevice onStart()",Toast.LENGTH_SHORT).show();
        mPlayer.start();
        super.onStart(intent,startId);
    }
    public void onDestroy(){
        Toast.makeText(MusicService.this,"MusicSevice onDestroy()",Toast.LENGTH_SHORT).show();
        mPlayer.stop();
        super.onDestroy();
    }
    public IBinder onBind(Intent intent){
        return null;
    }
}
